package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingLevelDto;
import com.zzyl.dto.NursingLevelPageParamVo;
import com.zzyl.service.NursingLevelService;
import com.zzyl.vo.NursingLevelVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequestMapping("/nursingLevel")
@RestController
@Api(tags = "护理等级有关接口操作")
public class NursingLevelController {

    @Autowired
    private NursingLevelService nursingLevelService;

    @GetMapping("/listAll")
    @ApiOperation("护理等级查询所有操作")
    public ResponseResult<List<NursingLevelVo>> getAll(){

        List<NursingLevelVo> list= nursingLevelService.getAll();
        return ResponseResult.success(list);
    }

    @PostMapping("/insert")
    @ApiOperation("护理等级添加功能")
    public ResponseResult add(@RequestBody NursingLevelDto nursingLevelDto){
        System.out.println("=============================="+nursingLevelDto);
        nursingLevelService.add(nursingLevelDto);
        return ResponseResult.success();
    }

    @GetMapping("/listByPage")
    @ApiOperation("护理等级分页查询功能")
    public ResponseResult<PageResponse<NursingLevelVo>> getByPage(NursingLevelPageParamVo paramVo){
        PageResponse<NursingLevelVo> vo =nursingLevelService.getByPage(paramVo);
        return ResponseResult.success(vo);
    }


    @GetMapping("/{id}")
    @ApiOperation("护理等级根据Id查询")
    public ResponseResult<NursingLevelVo> getById(@PathVariable Integer id){
        NursingLevelVo nursingLevelVo=nursingLevelService.getById(id);
        return ResponseResult.success(nursingLevelVo);
    }

    @PutMapping("/update")
    @ApiOperation("护理等级修改操作")
    public ResponseResult update(@RequestBody NursingLevelDto nursingLevelDto){
        nursingLevelService.update(nursingLevelDto);
        return ResponseResult.success();
    }

    @DeleteMapping("/delete/{id}")
    @ApiOperation("护理等级删除操作")
    public ResponseResult delete(@PathVariable Integer id){
        nursingLevelService.delete(id);
        return ResponseResult.success();
    }

    @PutMapping("/{id}/status/{status}")
    @ApiOperation("护理等级启用禁用操作")
    public ResponseResult updateStatus(@PathVariable Integer id,
                                       @PathVariable Integer status){
        nursingLevelService.updateStatus(id,status);
        return ResponseResult.success();
    }
}
